A = [2 2 4 4; 6 0 6 0];
B = [8 8 10 10; 2 4 2 4];
% Angaben aus dem Skriptum:
%A = [3 3 2 4; 4 8 6 6];
%B = [3 3 1 5; 0 -4 -2 -2];

MWa = mean(A')'
MWb = mean(B')'

C1=cov(A')
C2=cov(B')

fa=zeros(4,1);

for n=1:4
   d = (A(:,n)-MWa)'*(inv (C1))*(A(:,n)-MWa)
   fa(n,1)=-0.5*d*(-0.5*log(det(C1))+log (0.5));
end

fb=zeros(4,1);

for n=1:4
   d = (B(:,n)-MWb)'*(inv (C2))*(B(:,n)-MWb);
   fb(n,1)=-0.5*d*(-0.5*log(det(C2))+log (0.5));
end


C = [1 0; 0 1];
ga=zeros(4,1);

for n=1:4
   d = (A(:,n)-MWa)'*(inv (C))*(A(:,n)-MWa)
   ga(n,1)=-0.5*d*(-0.5*log(det(C))+log (0.5));
end

gb=zeros(4,1);

for n=1:4
   d = (B(:,n)-MWb)'*(inv (C))*(B(:,n)-MWb);
   gb(n,1)=-0.5*d*(-0.5*log(det(C))+log (0.5));
end


fa
fb
ga
gb


    